<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Artist class using Flyweight pattern
 *
 * @author techi
 */
class Artist {


    /**
     *
     * @var string
     */

    private $_name;

    /**
     *
     * @param string $name
     */

    public function __construct($name)
    {
         $this->_name = $name;
    }

    /**
     *
     * @return string
     */

    public function getName()
    {
        return $this->_name;
    }

    /**
     *
     * @return string
     */

    public function  __toString() {
        return $this->getName();
    }

    /**
     *
     * @var array
     */


    private static $_instances = array();

    /**
     *
     * @param string $name
     * @return Artist
     */

    public static function getInstance($name)
    {
        if (!isset(self::$_instances[$name])) {
            self::$_instances[$name] = new self($name);
        }
        return self::$_instances[$name];
    }
}
